import { createStore, applyMiddleware } from 'redux';
import thunkMiddleware from 'redux-thunk';
// import axiosMiddleware from 'redux-axios-middleware';
import { multiClientMiddleware } from 'redux-axios-middleware';

import createAxios from './axios';
import combineReducers from './reducers';

let clients = {
  default: {
    client: createAxios({
      baseURL: '/dev/api',
    }),
  },
};

const options = {};

console.log('process.env.NODE_ENV', process.env.NODE_ENV);

if (process.env.NODE_ENV === 'production') {
  clients = {
    default: {
      client: createAxios({
        baseURL: '/api',
      }),
    },
  };
}

const store = createStore(
  combineReducers,
  applyMiddleware(
    thunkMiddleware,
    multiClientMiddleware(clients, options),
  ),
);

export default store;
